<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
            list-style: none;
            font-size: 14px;
        }

        div {
            width: 300px;
            background-color: orchid;
            margin: 200px auto;
        }

        h2 {
            font-size: 30px;
            padding: 20px;
            line-height: 50px;
        }

        p {
            font-size: 20px;
            padding: 20px;
        }

        input {
            margin: 20px;
        }

        span {
            font-size: 20px;
            color: palegreen;
        }
    </style>
</head>

<body>
    <div>
        <h2>恭喜你，支付成功</h2>
        <p><span id="span">5</span> 秒后自动返回首页</p>
        <input type="button" id="btn" class="btn" value="立即返回">
    </div>
</body>

</html>
<script>
    window.onload = function () {
        var btn = document.getElementById('btn')
        var p = document.getElementsByTagName('p')[0]
        btn.onclick = function () {
            location.href = './daojishi10s.html'
        }
        var span = document.getElementById('span')
        var timer
        var num = 5;

        timer = setInterval(function () {
            span.innerHTML = num
            num--
            console.log(13);
            if (span.innerHTML == 0) {
                clearInterval(timer)
            }
            if (num == 0) {
                location.href = './daojishi10s.html'
            }
        }, 1000)
    }
</script>